
Ext.namespace("Ext.milan.pagejs.page_taskXmspr");
Ext.milan.pagejs.page_taskXmspr.userWin = null;
Ext.milan.pagejs.page_taskXmspr.subWin = null;
Ext.milan.pagejs.page_taskXmspr.REQUEST_ACTION = "taskXmspr";
var selectPostionTree = null;
Ext.milan.pagejs.page_taskXmspr.docLoadBeforeCallBack = function() {
};

Ext.milan.pagejs.page_taskXmspr.docOnReadyCallback = function() {

};

/**
 * 关闭子弹出窗口
 */
Ext.milan.pagejs.page_taskXmspr.closeSubWin = function() {
	Milan.commonutils.closeModelPop(Ext.milan.pagejs.page_taskXmspr.subWin);
};

/**
 * 关闭弹出窗口
 */
Ext.milan.pagejs.page_taskXmspr.closeWin = function(winName) {
	if(winName){
		if(winName=='inactivateConsignerWin')
			inactivateConsignerWin.closeDialog();
	}
	else
		Milan.commonutils.closeModelPop(Ext.milan.pagejs.page_taskXmspr.userWin);
};

/*------------------------ private methods -----------------------*/

/**
 * 查询所有
 */
Ext.milan.pagejs.page_taskXmspr._search = function() {
	Ext.milan.pagejs.common_utils.query(false, "taskXmspr/list.do");
};

Ext.milan.pagejs.page_taskXmspr._formCheck = function(frm) {
	function focusElement(el) {
		if(el.focus)
			el.focus();
	};
	return true;
};

/**
 * 保存信息
 */
Ext.milan.pagejs.page_taskXmspr._saveInfo = function(formId) {
	if(!Ext.milan.pagejs.page_taskXmspr._formCheck($(formId)))
		return;
		
	Milan.ajaxutility.formSubmit({
		form:formId,
		success:function(response)
		{
			Ext.milan.pagejs.page_taskXmspr.closeWin();
			Ext.milan.pagejs.page_taskXmspr.query();
		}
	});
};

/**
 * 条件查询列表
 */
Ext.milan.pagejs.page_taskXmspr.query = function() {
	Milan.pagejs.page_index.updateCurrentTabByForm("query_taskXmspr_list_form");
};

/**
 * 显示新建表单
 */
Ext.milan.pagejs.page_taskXmspr.showAddForm = function() {
	var url = Ext.milan.pagejs.page_taskXmspr.REQUEST_ACTION + "/create.do";
	Ext.milan.pagejs.page_taskXmspr.userWin = Milan.commonutils.createModelPop({
		title:"新建", 
		url:url,
		width:650
	});
};

/**
 * 显示编辑表单
 * 
 * @param ID
 */
Ext.milan.pagejs.page_taskXmspr.showEditForm = function(id) {
	var url = Ext.milan.pagejs.page_taskXmspr.REQUEST_ACTION + "/edit.do?id=" + id;
	Ext.milan.pagejs.page_taskXmspr.userWin = Milan.commonutils.createModelPop({
		title:"编辑",
		url:url,
		width:650
	});
};

/**
 * 保存新建用户信息
 */
Ext.milan.pagejs.page_taskXmspr.save = function(formId) {
	Ext.milan.pagejs.page_taskXmspr._saveInfo(formId);
};

/**
 * 保存编辑后的信息
 */
Ext.milan.pagejs.page_taskXmspr.edit = function(formId) {
	Ext.milan.pagejs.page_taskXmspr._saveInfo(formId);
};

Ext.milan.pagejs.page_taskXmspr.deleteForm = function(id) {
	var url = Ext.milan.pagejs.page_taskXmspr.REQUEST_ACTION + "/delete.do?id=" + id;
	new Milan.widget.ConfirmDialog("确认信息", "确认要删除该信息吗？", {
		confirmCallback: function() {
			Milan.ajaxutility.formSubmit({
				url: url,
				method: 'post',
				success: function(response, option)
				{
					Ext.milan.pagejs.page_taskXmspr.query();
				}
			});
		}
	});	
};

/**
 * 查看详情
 * 
 * @param entityId 用户ID
 */
Ext.milan.pagejs.page_taskXmspr.viewDetail = function(entityId) {
	var url = Ext.milan.pagejs.page_taskXmspr.REQUEST_ACTION + "/show.do?id=" + entityId;
	Ext.milan.pagejs.page_taskXmspr.userWin = Milan.commonutils.createModelPop({
		title:"详细信息",
		url:url,
		width:650
	});
};

Ext.milan.pagejs.page_taskXmspr.selectUsers = function(ele,str) {

	new Milan.widget.Selector({
		orgType:"12",
		title:"选择人员",
		deptUrl:"dept/selectDept.do?",
		quickSelectUrl:"user/quickUser.do?",
		searchUrl:"user/searchUser.do?",
		isRecentEnable :false,
		isUpdateRecentEnable :false,
		isDeptSelEnable:true
	},
	true,
	{
		onSelectedCallBack : function(arr)
		{
			var formEle = ele.form;
			var obj = eval("formEle."+str);
			obj.value=arr[0].id;
			obj = eval("formEle."+"select"+str);
			obj.value=arr[0].name;
		}
	});
};

Ext.milan.pagejs.page_taskXmspr.clearUsers = function(ele,str){
	var formEle = ele.form;
	var obj = eval("formEle."+str);
	obj.value="";
	obj = eval("formEle."+"select"+str);
	obj.value="";
};